# Definition for a binary tree node.
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None


class Solution:
    def isSymmetric(self, root: TreeNode) -> bool:
        search_list = [root]
        return self.search(search_list)

    def search(self, list_in):
        search_list = []
        for i in range(len(list_in)):
            if list_in[i]:
                search_list.append(list_in[i].left)
                search_list.append(list_in[i].right)
                list_in[i] = list_in[i].val
        if list_in != list_in[::-1]:
            return False
        if search_list:
            return self.search(search_list)
        return True
